

class RunningConfigInteration:
    def __init__(self, dbconn, logger):
        self._dbconn = dbconn
        self._logger = logger

    def getOldRunConfigNameList(self):
        if self._dbconn.tableExists('tIniceRuns'):
            sql = "SELECT id, name FROM tIniceRuns"
            rows = self._dbconn.read(sql)
            return rows
        # TODO:

    def getDatasetNameList(self):
        if self._dbconn.tableExists('tDataset'):
            sql = "SELECT id, name FROM tDataset"
            rows = self._dbconn.read(sql)
            return rows
        # TODO:

    def getOldRunConfig(self, id):
        if self._dbconn.tableExists('tIniceRuns'):
            sql = "SELECT id, datasetId, observerGeneratorClassName, numOfObservers FROM tIniceRuns WHERE id='%d'" % id
            rows = self._dbconn.read(sql)
            return rows[0]
        # TODO

    def getTDatasetName(self, id):
        if self._dbconn.tableExists('tDataset'):
            sql = "SELECT name FROM tDataset WHERE id='%d'" % id
            rows = self._dbconn.read(sql)
            return rows[0][0]
        # TODO

    def getObConfigDetail(self, tIniceRunsId):
        # One2OneDistance N2NDistances Cluster Estimator  Cluster Estimator Config DBid
        sql = "SELECT One2OneDistanceClassName, N2NDistancesClassName, clusterEstimatorClassName from tObserver WHERE sessionId='%d'" % tIniceRunsId
        rows = self._dbconn.read(sql)
        return rows

    def getDatasetDetail(self, tDatasetId):
        sql = "SELECT name, ClassName, nRows, nCols, numOfClusters from tDataset WHERE id='%d'" % tDatasetId
        rows = self._dbconn.read(sql)
        return rows[0]

    def getDatasetAllDetail(self, tDatasetId):
        sql = "SELECT * from tDataset WHERE id='%d'" % tDatasetId
        rows = self._dbconn.read(sql)
        return rows[0]
